home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / ABUSESRC.ZIP / AbuseSrc / abuse / src / username.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-11  |  447 b   |  28 lines

  1. #if defined( __WATCOMC__ ) || defined( __POWERPC__ )
  2. char *get_username() { return "DOS user"; }
  3.  
  4. #else
  5.   
  6. #include    <stdio.h>
  7. #include    <pwd.h>
  8. #include    <sys/types.h>
  9. #include        <unistd.h>
  10.  
  11. char *get_username()
  12. {
  13.   struct passwd        *pw;
  14.   char            *name;
  15.  
  16.   if (!(name = getlogin()))
  17.   {
  18.     if ((pw = getpwuid (getuid())))
  19.       return pw->pw_name;
  20.     else
  21.       return "UNIX user";
  22.   } else return name; 
  23. }
  24.  
  25. #endif
  26.  
  27.  
  28.